* Note: referenced excel files in $folder contain the outputs saved in the log-files of various analysis do-files. This do-file saves graphs into $folder.

global folder "" // specify folder here //

* Construct: Figure 1: Wage Trajectory of Treated and Control Individuals Around the Event Time
import excel "$folder\EventStudy_Marc2025.xlsx", sheet("descr") firstrow clear
twoway scatter wage0_0 wage1_0 et, mcolor(blue red) msymbol(Oh X ) msize(medium large )  ytitle("Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid)) legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) legend(on order(1 "Accident=0" 2 "Accident=1 & Absence=1" ) region(lstyle(none)) col(2) pos(6)) xline(0, lcolor(gs10)) 
graph export "$folder\EventStudy_wage_descr_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage_descr_Marc2025.eps", as(eps) replace

* Construct: Figure 2: Health Outcomes of Individuals With an Accident

import excel "$folder\EventStudy_27Aug2024.xlsx", sheet("health_descr") firstrow clear

	twoway scatter hosp0 hosp1 et, mcolor(black red) msymbol(X Oh) msize(large medium) xlab(-24(6)24) xtitle("Months Since Accident") legend(on order(1 "Absence=0" 2 "Absence=1") region(lstyle(none)) col(2) pos(6)) graphregion(color(white)) bgcolor(white) xline(0, lcolor(gs12)) ytitle("Probability of Hospital Stay") 
graph export "$folder\EventStudy_hosp_descr.pdf", as(pdf) replace
graph export "$folder\EventStudy_hosp_descr.eps", as(eps) replace

	twoway scatter drug0 drug1 et, mcolor(black red) msymbol(X Oh) msize(large medium) xlab(-24(6)24) xtitle("Months Since Accident") legend(on order(1 "Absence=0" 2 "Absence=1") region(lstyle(none)) col(2) pos(6)) graphregion(color(white)) bgcolor(white) xline(0, lcolor(gs12)) ytitle("Drug Spending (HUF)") ylab(0(5000)20000)
graph export "$folder\EventStudy_drug_descr.pdf", as(pdf) replace
graph export "$folder\EventStudy_drug_descr.eps", as(eps) replace

	twoway scatter J0 J1 et, mcolor(black red) msymbol(X Oh) msize(large medium) xlab(-24(6)24) xtitle("Months Since Accident") legend(on order(1 "Absence=0" 2 "Absence=1") region(lstyle(none)) col(2) pos(6)) graphregion(color(white)) bgcolor(white) xline(0, lcolor(gs12)) ytitle("Probability of Spending on Antiinfectives")  ylab(0(.02).1)
graph export "$folder\EventStudy_J_descr.pdf", as(pdf) replace
graph export "$folder\EventStudy_J_descr.eps", as(eps) replace

	twoway scatter M0 M1 et, mcolor(black red) msymbol(X Oh) msize(large medium) xlab(-24(6)24) xtitle("Months Since Accident") legend(on order(1 "Absence=0" 2 "Absence=1") region(lstyle(none)) col(2) pos(6)) graphregion(color(white)) bgcolor(white) xline(0, lcolor(gs12)) ytitle("Probability of Spending on Muscoloskeletal Drugs") ylab(0(.02).1)
graph export "$folder\EventStudy_M_descr.pdf", as(pdf) replace
graph export "$folder\EventStudy_M_descr.eps", as(eps) replace

	twoway scatter N0 N1 et, mcolor(black red) msymbol(X Oh) msize(large medium) xlab(-24(6)24) xtitle("Months Since Accident") legend(on order(1 "Absence=0" 2 "Absence=1") region(lstyle(none)) col(2) pos(6)) graphregion(color(white)) bgcolor(white) xline(0, lcolor(gs12)) ytitle("Probability of Spending on Psychoanaleptics") ylab(0(.02).1)
graph export "$folder\EventStudy_N06_descr.pdf", as(pdf) replace
graph export "$folder\EventStudy_N06_descr.eps", as(eps) replace

	twoway scatter dr0 dr1 et, mcolor(black red) msymbol(X Oh) msize(large medium) xlab(-24(6)24) xtitle("Months Since Accident") legend(on order(1 "Absence=0" 2 "Absence=1") region(lstyle(none)) col(2) pos(6)) graphregion(color(white)) bgcolor(white) xline(0, lcolor(gs12)) ytitle("Number of Outpatient Physician Visits") 
graph export "$folder\EventStudy_dr_descr.pdf", as(pdf) replace
graph export "$folder\EventStudy_dr_descr.eps", as(eps) replace

* Construct: Figure 4: Event Study Estimates of the Effect of Absence Following an Accident, on Weekly Hours Worked

import excel "$folder\EventStudy_Marc2025.xlsx", sheet("reg") firstrow clear

twoway scatter wh et, mcolor(blue) || rcap wh_h wh_l et, xline(0, lcolor(gs10)) ytitle("Effect on Weekly Hours Worked") yline(0, lcolor(gs10) lpattern(solid)) legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-1(.2).2)
graph export "$folder\EventStudy_hours_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_hours_Marc2025.eps", as(eps) replace

twoway scatter loghours et, mcolor(blue) || rcap loghours_h loghours_l et, xline(0, lcolor(gs10)) ytitle("Effect on Log Weekly Hours Worked") yline(0, lcolor(gs10) lpattern(solid)) legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01)
graph export "$folder\EventStudy_log_hours_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_log_hours_Marc2025.eps", as(eps) replace

* Construct: Figure 3: Event Study Estimates of the Effect of Absence Following an Accident on Hourly Deflated Log-Wage
twoway scatter wDID et, mcolor(blue) || rcap wDID_h wDID_l et, xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid)) legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01)
graph export "$folder\EventStudy_wageDID_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wageDID_Marc2025.eps", as(eps) replace

* Construct: Figure 9: Event Study Estimates of the Effect of Absence Following an Accident, on Estimated AKM Firm Effect (Capturing Firm-Specific Wage Premium)

twoway scatter FEDID et, mcolor(blue) || rcap FEDID_h FEDID_l et, xline(0, lcolor(gs10)) ytitle("Effect on AKM Firm Effect") yline(0, lcolor(gs10) lpattern(solid)) legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01)
graph export "$folder\EventStudy_feDID_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_feDID_Marc2025.eps", as(eps) replace

* Construct: Figure A4 & B7: Robustness Checks (Matching and Excluding Co-workers at Small Firms): Event Study Estimates of the Effect of Absence Following an Accident, on Hourly Deflated Log-Wage
* and
* Robustness Check (Excluding Co-workers at Small Firms): Event Study Estimates of the Effect of Absence Following an Accident, on AKM Firm Effect

gen et0=et-.1
gen et1=et
gen et2=et+.1
twoway rcap wDID_h wDID_l et0, lcolor(black*.5) ||  rcap lcoworker_w_h lcoworker_w_l et1, lcolor(red*.5) ||  rcap lnocoworker_w_h lnocoworker_w_l et2, lcolor(blue*.5) || scatter wDID et0, mcolor(black) msymbol(X) msize(large) || scatter lcoworker_w et1, mcolor(red) msymbol(Oh) msize(medium) || scatter lnocoworker_w et2, mcolor(blue) msymbol(square) msize(medium)   xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(4 "Baseline" 5 "Co-worker matching" 6 "Excluding co-workers at small firms" ) region(lstyle(none)) col(3) pos(6))
graph export "$folder\EventStudy_nocoworker_wage_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_nocoworker_wage_Marc2025.eps", as(eps) replace


twoway scatter FEDID et0, mcolor(black) msymbol(X) msize(large) || scatter lnocoworker_FE et1, mcolor(red) msize(medium) ||  rcap FEDID_h FEDID_l et0, lcolor(black*.5) || rcap lnocoworker_FE_h lnocoworker_FE_l et1, lcolor(red*.5)   xline(0, lcolor(gs10)) ytitle("Effect on AKM Firm Effect") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(1 "Baseline" 2 "Excluding co-workers at small firms" ) region(lstyle(none)) col(3) pos(6))
graph export "$folder\EventStudy_nocoworker_firmFE_Marc2025_r.pdf", as(pdf) replace
graph export "$folder\EventStudy_nocoworker_firmFE_Marc2025_r.eps", as(eps) replace

* Construct: Figure A3 & B6: Robustness Check on the Sample of Those Suffering an Accident: Event Study Estimates of the Effect of Absence Following an Accident, on Hourly Deflated Log-Wage
* and
* Robustness Check on the Sample of Those Suffering an Accident: Event Study Estimates of the Effect of Absence Following an Accident, on AKM Firm Effect

twoway  rcap wDID_h wDID_l et0, lcolor(black*.5) ||  rcap timing1214_base_w_h timing1214_base_w_l et, lcolor(blue*.5) ||  rcap timing1214_w_h timing1214_w_l et2, lcolor(red*.5) xline(0, lcolor(gs10)) || scatter wDID et0, mcolor(black) msymbol(X) msize(large) || scatter timing1214_base_w et, mcolor(blue) msymbol(Oh) msize(medium) || scatter timing1214_w et2, mcolor(red) msymbol(square) msize(medium) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(4 "Baseline sample, accidents in 2012-2017" 5 "Baseline sample, accidents in 2012-2014" 6 "Accident sample only, accidents in 2012-2014" ) region(lstyle(none)) col(1) pos(6))
graph export "$folder\EventStudy_timing1214_wage_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_timing1214_wage_Marc2025.eps", as(eps) replace

twoway   rcap FEDID_h FEDID_l et0, lcolor(black*.5) ||  rcap timing1014_base_FE_h timing1014_base_FE_l et, lcolor(blue*.5) ||  rcap timing1014_FE_h timing1014_FE_l et2, lcolor(red*.5) || scatter FEDID et0, mcolor(black) msymbol(X) msize(large) || scatter timing1014_base_FE et, mcolor(blue) msymbol(Oh) msize(medium) || scatter timing1014_FE et2, mcolor(red) xline(0, lcolor(gs10))  msymbol(square) msize(medium)  ytitle("Effect on AKM Firm Effect") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(4 "Baseline sample, accidents in 2012-2017" 5 "Baseline sample, accidents in 2010-2014" 6 "Accident sample only, accidents in 2010-2014" ) region(lstyle(none)) col(1) pos(6))
graph export "$folder\EventStudy_timing1014_firmFE_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_timing1014_firmFE_Marc2025.eps", as(eps) replace

* Construct: Figure A1: Allowing for Treatment Effect Heterogeneity Over Time: Event Study Estimates of the Effect of Absence Following an Accident on Hourly Deflated Log-Wage
cap drop et0 et1
gen et0=et-.1
gen et1=et+.1

twoway scatter w0 et0, mcolor(black) msymbol(X) msize(large) || scatter Sun_w et1, mcolor(red) msize(medium)  ||  rcap w0_h w0_l et0, lcolor(black*.5)  ||  rcap Sun_w_h Sun_w_l et1, lcolor(red*.5) xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(1 "Baseline" 2 "Sun-Abraham") region(lstyle(none)) col(2) pos(6))
graph export "$folder\EventStudy_robDID_wage_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_robDID_wage_Marc2025.eps", as(eps) replace

* Construct: Figure B4: Allowing for Treatment Effect Heterogeneity Over Time: Event Study Estimates of the Effect of Absence Following an Accident, on AKM Firm Effect

twoway scatter FE0 et0, mcolor(black) msymbol(X) msize(large) || scatter Sun_FE et1, mcolor(red) msize(medium) ||  rcap FE0_h FE0_l et0, lcolor(black*.5) || rcap Sun_FE_h Sun_FE_l et1, lcolor(red*.5) xline(0, lcolor(gs10)) ytitle("Effect on AKM Firm Effect") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(1 "Baseline" 2 "Sun-Abraham") region(lstyle(none)) col(2) pos(6))
graph export "$folder\EventStudy_robDID_firmFE_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_robDID_firmFE_Marc2025.eps", as(eps) replace

* Construct Figure B2: Event Study Estimates of the Effect of Absence Following an Accident, on Hourly Deflated Log Wage, Including Absences Up To 11 Months-.03

twoway scatter wDID et0, mcolor(black) msymbol(X) msize(large) || scatter d12_w et1, mcolor(red) msize(medium)  ||  rcap wDID_h wDID_l et0, lcolor(black*.5) ||  rcap d12_w_h d12_w_l et1, lcolor(red*.5) xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01) legend(on order(1 "Baseline (1-5 months absence)" 2 "Extended sample (1-11 months absence)") region(lstyle(none)) col(2) pos(6))
graph export "$folder\EventStudy_12mo_wage_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_12mo_wage_Marc2025.eps", as(eps) replace

* Construct: Figure 5: Event Study Estimates of the Effect of Absence Following an Accident, on Occupation Characteristics, For All and by Occupation

import excel "$folder\EventStudy_Marc2025.xlsx", sheet("onet") firstrow clear

gen et0=et-.15
gen et1=et+.15

twoway scatter phys et0, mcolor(red) msymbol(square) msize(medium) ||  scatter wphys et, mcolor(black) msymbol(Oh) msize(medium) ||  scatter bphys et1, mcolor(blue) msymbol(X) msize(large) || rcap phys_l phys_h et0, lcolor(red) || rcap wphys_l wphys_h et, lcolor(black) || rcap bphys_l bphys_h et1, lcolor(blue)  xline(0, lcolor(gs10)) ytitle("Effect on Standardized Physical Score") yline(0, lcolor(gs10) lpattern(solid)) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8)  legend(on order(1 "All Workers" 2 "White Collar Workers" 3 "Blue Collar Workers") region(lstyle(none)) col(3) pos(6))
graph export "$folder\EventStudy_pyhs_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_pyhs_Marc2025.eps", as(eps) replace

twoway scatter stress et0, mcolor(red) msymbol(square) msize(medium) ||  scatter wstress et, mcolor(black) msymbol(Oh) msize(medium) ||  scatter bstress et1, mcolor(blue) msymbol(X) msize(large) || rcap stress_l stress_h et0, lcolor(red) || rcap wstress_l wstress_h et, lcolor(black) || rcap bstress_l bstress_h et1, lcolor(blue)  xline(0, lcolor(gs10)) ytitle("Effect on Standardized Stress Score") yline(0, lcolor(gs10) lpattern(solid)) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8)  legend(on order(1 "All Workers" 2 "White Collar Workers" 3 "Blue Collar Workers") region(lstyle(none)) col(3) pos(6)) ylab(-.04(.02).04)
graph export "$folder\EventStudy_stress_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_stress_Marc2025.eps", as(eps) replace

* Construct: Figure A6: Event Study Estimates of the Effect of Absence Following an Accident, on Hourly Deflated Log-Wage, for Individuals With Accident but No Absence Spell

import excel "$folder\EventStudy_Marc2025.xlsx", sheet("noABS") firstrow clear

twoway scatter w et, mcolor(blue) || rcap w_h w_l et, xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid)) legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Accident") xlab(-8(1)-1 1(1)8) ylab(-.02(.02).04)
graph export "$folder\EventStudy_wage_Marc2025_noABS.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage_Marc2025_noABS.eps", as(eps) replace

import excel "$folder\EventStudy_Marc2025.xlsx", sheet("csdid") firstrow clear

keep if et<9
drop if et==2
replace et=et-1 if et>2

* Construct: Figure A2: Event Study Estimates of the Effect of Absence Following an Accident, on Hourly Deflated Log-Wage, with Estimation Method of Callaway and Sant’Anna (2021)

twoway scatter wage et, mcolor(blue) || rcap wage_h wage_l et, xline(.5, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Accident") xlab(-7(1)-1 2 "3" 3 "4" 4 "5" 5 "6" 6 "7" 7 "8") ylab(-.03(.01).01) yline(0, lcolor(gs10) lpattern(solid)) 
graph export "$folder\csdid_wage_Marc2025.pdf", as(pdf) replace
graph export "$folder\csdid_wage_Marc2025.eps", as(eps) replace

* Construct: Figure B5: Event Study Estimates of the Effect of Absence Following an Accident, on AKM Firm Effect, with Estimation Method of Callaway and Sant’Anna (2021)

twoway scatter FE et, mcolor(blue) || rcap FE_h FE_l et, xline(.5, lcolor(gs10)) ytitle("Effect on AKM Firm Effect") legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Accident") xlab(-7(1)-1 2 "3" 3 "4" 4 "5" 5 "6" 6 "7" 7 "8") ylab(-.03(.01).01) yline(0, lcolor(gs10) lpattern(solid)) 
graph export "$folder\csdid_FE_Marc2025.pdf", as(pdf) replace
graph export "$folder\csdid_FE_Marc2025.eps", as(eps) replace

* Construct: Figure B1: Employment Rate

import excel "$folder\EventStudy_Marc2025.xlsx", sheet("emp") firstrow clear

twoway scatter emp et, mcolor(blue) || rcap emp_h emp_l et, xline(0, lcolor(gs10)) ytitle("Effect on Employment Rate") legend(off) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) yline(0, lcolor(gs10) lpattern(solid)) ylab(-.02(.01).02)
graph export "$folder\emp_Marc2025.pdf", as(pdf) replace
graph export "$folder\emp_Marc2025.eps", as(eps) replace

twoway scatter control treated et,  mcolor(black red) msymbol(X Oh) msize(large medium) xline(0, lcolor(gs10)) ytitle("Employment Rate") legend(on order(1 "Accident=0" 2  "Accident=1 & Absence=1") region(lstyle(none)) col(2) pos(6)) lcolor(blue*.5) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) yline(0, lcolor(gs10) lpattern(solid)) ylab(0(.2)1)
graph export "$folder\emp_descr_Marc2025.pdf", as(pdf) replace
graph export "$folder\emp_descr_Marc2025.eps", as(eps) replace

*Construct: Figure A5: Event Study Estimates of the Effect of Absence Following an Accident on Hourly Deflated Log-Wage, on the Propensity Score-Weighted Sample and Using Controls After Matching Across Firms

import excel "$folder\Matching_Marc2025.xlsx", sheet("match_result") firstrow clear
cap drop et0 et1
gen et0=et-.1
gen et1=et+.1

twoway rcap w_h w_l et0, lcolor(red*.5)  || rcap wm_h wm_l et1,lcolor(blue*.5) || scatter w et0, mcolor(red) msize(medium) msymbol(Oh) || scatter wm et1, mcolor(blue)  msymbol(square) msize(medium) xline(0, lcolor(gs10))  ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid)) xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.03(.01).01)  legend(on order(3 "Propensity score weighting" 4 "Matching across firms") region(lstyle(none)) col(2) pos(6))
graph export "$folder\EventStudy_wage_match_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage_match_Marc2025.eps", as(eps) replace

* Construct: Figure 10: Event Study Estimates of the Effect of Absence Following an Accident, on Co-Workers’ Hourly Deflated Log-Wage

import excel "$folder\coworker-data_July2025.xlsx", sheet("Sheet1") firstrow clear

cap drop et0 et1 et2
gen et0=et-.1
gen et1=et+.1
gen et2=et+.3

twoway scatter bel250 et0, mcolor(red) msymbol(square) msize(medium) || scatter ab250 et1, mcolor(blue) msymbol(Oh) msize(medium) ||  rcap bel250_h bel250_l et0, lcolor(red*.5) ||  rcap ab250_h ab250_l et1, lcolor(blue*.5) xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") ylab(-0.02(0.02)0.04) xlab(-8(1)-1 1(1)8) legend(on order(1 "Firm Size: Below 250" 2 "Firm Size: Above 250") region(lstyle(none)) col(2) pos(6))
graph export "$folder\ES_coworker_letszam_ALL_250_July2025.pdf", as(pdf) replace
graph export "$folder\ES_coworker_letszam_ALL_250_July2025.eps", as(eps) replace

twoway scatter bel619 et0, mcolor(red) msymbol(square) msize(medium) || scatter ab619 et1, mcolor(blue) msymbol(Oh) msize(medium) ||  rcap bel619_h bel619_l et0, lcolor(red*.5) ||  rcap ab619_h ab619_l et1, lcolor(blue*.5) xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") ylab(-0.02(0.02)0.04) xlab(-8(1)-1 1(1)8) legend(on order(1 "Firm Size: Below Median" 2 "Firm Size: Above Median") region(lstyle(none)) col(2) pos(6))
graph export "$folder\ES_coworker_letszam_ALL_med_July2025.pdf", as(pdf) replace
graph export "$folder\ES_coworker_letszam_ALL_med_July2025.eps", as(eps) replace

twoway scatter bel250_ten et0, mcolor(red) msymbol(square) msize(medium) || scatter bel619_ten et1, mcolor(blue) msymbol(Oh) msize(medium) || scatter bel500_ten et2, mcolor(black) msymbol(X) msize(large) ||  rcap bel250_ten_h bel250_ten_l et0, lcolor(red*.5) ||  rcap bel619_ten_h bel619_ten_l et1, lcolor(blue*.5) ||  rcap bel500_ten_h bel500_ten_l et2, lcolor(black*.5) xline(0, lcolor(gs10)) ytitle("Effect on Hourly Deflated Log-Wage") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") ylab(-0.02(0.02)0.04) xlab(-8(1)-1 1(1)8) legend(on order(1 "Firm Size: Below 250" 2 "Firm Size: Below Median" 3 "Firm Size: Below 500") region(lstyle(none)) col(3) pos(6))
graph export "$folder\ES_coworker_letszam_LONGTEN_July2025.pdf", as(pdf) replace
graph export "$folder\ES_coworker_letszam_LONGTEN_July2025.eps", as(eps) replace

* Construct: Figure 8: Event Study Estimates of the Effect of Absence Following an Accident, on the Propensity to Switch to Higher and to Lower AKM Firms; Across and Within Quarters

import excel "$folder\JJ_data.xlsx", sheet("Sheet1") firstrow clear
cap drop et0 et1
gen et0=et-.1
gen et1=et+.1

twoway scatter down_b et0, mcolor(red) msymbol(square) msize(medium) || scatter up_b et1, mcolor(blue) msymbol(Oh) msize(medium) ||  rcap down_b_h down_b_l et0, lcolor(red*.5) ||  rcap up_b_h up_b_l et1, lcolor(blue*.5) xline(0, lcolor(gs10)) ytitle("Effect on Switching (Relative to Previous Quarter)") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.01(.01).02) legend(on order(1 "Down To Lower AKM Firm" 2 "Up To Higher AKM Firm") region(lstyle(none)) col(2) pos(6))
graph export "$folder\switch_acrossQ.pdf", as(pdf) replace
graph export "$folder\switch_acrossQ.eps", as(eps) replace

twoway scatter down_w et0, mcolor(red) msymbol(square) msize(medium) || scatter up_w et1, mcolor(blue) msymbol(Oh) msize(medium) ||  rcap down_w_h down_w_l et0, lcolor(red*.5) ||  rcap up_w_h up_w_l et1, lcolor(blue*.5) xline(0, lcolor(gs10)) ytitle("Effect on Switching (Within Quarter)") yline(0, lcolor(gs10) lpattern(solid))   xtitle("Quarters Before Accident                            Quarters After Return to Work") xlab(-8(1)-1 1(1)8) ylab(-.01(.01).02) legend(on order(1 "Down To Lower AKM Firm" 2 "Up To Higher AKM Firm") region(lstyle(none)) col(2) pos(6))
graph export "$folder\switch_withinQ.pdf", as(pdf) replace
graph export "$folder\switch_withinQ.eps", as(eps) replace

* Construct: Figure 6: Heterogeneity in the Estimates of the Event Study Model (4), on Hourly Deflated Log-Wage, by Baseline AKM Firm Effect, Tenure, Age, Occupation, and Gender
* Construct: Figure 7: Heterogeneity in the Estimates of the Event Study Model (4), on Hourly Deflated Log-Wage, by Type of Injury, Body Part Injured, and Length of Absence

import excel "$folder\EventStudy_Marc2025.xlsx", sheet("heterog") firstrow clear
keep if table==1

drop if idvnum<7 | idvnum>22

	label define idvnum ///
		2 "Pre-Wage <= Median" ///
		1 "Pre-Wage > Median" ///
		5 "Pre-Firm FE <= Median" ///
		4 "Pre-Firm FE > Median" ///
		7 "Female" ///
		8 "Male" ///
		10 "White-Collar" ///
		11 "Blue-Collar" ///
		13 "Age 20-29" ///
		14 "Age 30-39" ///
		15 "Age 40-50" ///
		17 "Tenure < 2Y" ///
		18 "Tenure >= 2Y" ///
		20 "Pre-Firm FE <= Median" ///
		21 "Pre-Firm FE > Median", ///
		 replace
	label values idvnum idvnum

	levelsof idvnum, local(lidvnum)
	foreach l in _wt1 {
	format coeffb`l' %9.3f
	twoway (rcap coeffc1`l' coeffc2`l' idvnum, hor color(navy)) ///
			(dot coeffb`l' idvnum, hor  ylabel(`lidvnum', valuelabel angle(0) labsize(medium)) color(navy) mlabel(coeffb`l') mlabp(2) mlabsize(medium) mlabcolor(black)), ///
			xline(0, lcolor(red)) 	title("", size(medium)) subtitle("", size(med)) ytitle("")	graphregion(color(white))	legend(order(2 "Estimate" 1 "95% CI") symxsize(*0.75) pos(6) col(2))
	}
graph export "$folder\EventStudy_wage_r1_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage_r1_Marc2025.eps", as(eps) replace

			
	levelsof idvnum, local(lidvnum)
	foreach l in _wt2 {
	format coeffb`l' %9.3f
	twoway (rcap coeffc1`l' coeffc2`l' idvnum, hor color(navy)) ///
			(dot coeffb`l' idvnum, hor  ylabel(`lidvnum', valuelabel angle(0) labsize(medium)) color(navy) mlabel(coeffb`l') mlabp(2) mlabsize(medium) mlabcolor(black)), ///
			xline(0, lcolor(red)) 	title("", size(medium)) subtitle("", size(med)) ytitle("")	graphregion(color(white))	legend(order(2 "Estimate" 1 "95% CI") symxsize(*0.75) pos(6) col(2))
	}
graph export "$folder\EventStudy_wage_r2_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage_r2_Marc2025.eps", as(eps) replace


import excel "$folder\EventStudy_Marc2025.xlsx", sheet("heterog") firstrow clear
keep if table==2

	label define idvnum ///
		1 "Upper Arm" ///
		2 "Elbow and Forearm" ///
		3 "Wrist and Hand" ///
		4 "Hip and Thigh" ///
		5 "Knee and Lower Leg" ///
		6 "Ankle and Foot" ///
		8 "Dislocation, Sprain, Wound" ///
		9 "Fracture" ///
		11 "Absent for 1-3 Months" ///
		12 "Absent for 4-5 Months", ///
		 replace
	label values idvnum idvnum

	levelsof idvnum, local(lidvnum)
	foreach l in _wt1 {
	format coeffb`l' %9.3f
	twoway (rcap coeffc1`l' coeffc2`l' idvnum, hor color(navy)) ///
			(dot coeffb`l' idvnum, hor xlabel(-0.04(0.01)0.02) ylabel(`lidvnum', valuelabel angle(0) labsize(medium)) color(navy) mlabel(coeffb`l') mlabp(2) mlabsize(medium) mlabcolor(black)), ///
			xline(0, lcolor(red)) 	title("", size(medium)) subtitle("", size(med)) ytitle("")	graphregion(color(white))	legend(order(2 "Estimate" 1 "95% CI") symxsize(*0.75) pos(6) col(2))

	}
graph export "$folder\EventStudy_wage2_r1_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage2_r1_Marc2025.eps", as(eps) replace

	levelsof idvnum, local(lidvnum)
	foreach l in _wt2 {
	format coeffb`l' %9.3f
	twoway (rcap coeffc1`l' coeffc2`l' idvnum, hor color(navy)) ///
			(dot coeffb`l' idvnum, hor xlabel(-0.04(0.02)0.05) ylabel(`lidvnum', valuelabel angle(0) labsize(medium)) color(navy) mlabel(coeffb`l') mlabp(2) mlabsize(medium) mlabcolor(black)), ///
			xline(0, lcolor(red)) 	title("", size(medium)) subtitle("", size(med)) ytitle("")	graphregion(color(white))	legend(order(2 "Estimate" 1 "95% CI") symxsize(*0.75) pos(6) col(2))

	}
graph export "$folder\EventStudy_wage2_r2_Marc2025.pdf", as(pdf) replace
graph export "$folder\EventStudy_wage2_r2_Marc2025.eps", as(eps) replace